Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
postgres-date
Advanced tools
The postgres-date npm package is designed to parse and handle dates in PostgreSQL format. It provides functionalities for converting PostgreSQL date and timestamp strings into JavaScript Date objects. This can be particularly useful when working with PostgreSQL databases in Node.js applications, ensuring that date and timestamp data is correctly handled and manipulated.
Parsing PostgreSQL date strings
This feature allows the conversion of PostgreSQL date strings into JavaScript Date objects. It's useful for handling date information retrieved from a PostgreSQL database.
"const parseDate = require('postgres-date');
const dateString = '2023-04-01';
const dateObject = parseDate(dateString);
console.log(dateObject); // Outputs a JavaScript Date object for 2023-04-01"
Parsing PostgreSQL timestamp strings
Similar to parsing date strings, this feature enables the parsing of PostgreSQL timestamp strings, including those with time information, into JavaScript Date objects.
"const parseDate = require('postgres-date');
const timestampString = '2023-04-01 12:00:00';
const dateObject = parseDate(timestampString);
console.log(dateObject); // Outputs a JavaScript Date object for 2023-04-01 12:00:00"
Moment is a widely used package for parsing, validating, manipulating, and formatting dates. It supports multiple date formats and locales. Compared to postgres-date, Moment offers a broader range of functionalities beyond just parsing PostgreSQL date strings, including operations on dates and extensive formatting options.
date-fns is a modern JavaScript date utility library offering a comprehensive set of date manipulation functions. It provides functions for parsing, formatting, and manipulating dates. Unlike postgres-date, which is focused on PostgreSQL date strings, date-fns offers a wide array of utilities that can be used with various date formats and is designed with a modular approach.
Luxon is a powerful library for dealing with dates and times in JavaScript. It offers capabilities for parsing, formatting, manipulating, and querying dates and times. Luxon is built on the Intl API and provides time zone support. While postgres-date is specialized for PostgreSQL date strings, Luxon provides a more comprehensive solution for date and time handling, including support for internationalization.
Postgres date output parser
This package parses date/time outputs from Postgres into Javascript Date
objects. Its goal is to match Postgres behavior and preserve data accuracy.
If you find a case where a valid Postgres output results in incorrect parsing (including loss of precision), please create a pull request and provide a failing test.
Supported Postgres Versions: >= 9.6
All prior versions of Postgres are likely compatible but not officially supported.
npm install --save postgres-date
const parse = require('postgres-date')
parse('2011-01-23 22:15:51Z')
// => 2011-01-23T22:15:51.000Z
parse(isoDate)
-> date
Required
Type: string
A date string from Postgres.
The following semantic versioning increments will be used for changes:
MIT © Ben Drucker
FAQs
Postgres date column parser
We found that postgres-date demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.